package mearth;
import processing.core.PApplet;
import processing.core.PImage;


public class ME_Sea_extract extends PApplet {

	PImage img;
	
	public void setup(){
		img = loadImage("map004.png");
		int sc = img.pixels[0];
		int WHITE = color(255);
		
		img.loadPixels();
		
		for(int i = 1; i < img.pixels.length; i++){
			if(img.pixels[i] != sc){
				int r = (img.pixels[i] & 0x00ff0000) >> 16;
				int g = (img.pixels[i] & 0x0000ff00) >> 8;
				int b = (img.pixels[i] & 0x000000ff);
				if(b > g && b > r + 64)
					img.pixels[i] = sc;
				else
					img.pixels[i] = WHITE;
			}
		}
		img.updatePixels();
		img.save("sea002.png");
		println("Finished");
		exit();
	}
}
